package cn.yunhe.action;

import cn.yunhe.service.KeySearchService;
import cn.yunhe.util.BaseUtil;
import lombok.Data;
import net.sf.json.JSONArray;

import java.io.IOException;
import java.io.PrintWriter;

@Data
public class KeySearchAction extends BaseUtil {
    private String keyword;
    PrintWriter out;
    public void byName() throws IOException {
        out=getResponse().getWriter();
        KeySearchService keySearchService=new KeySearchService();
        JSONArray jsonArray=keySearchService.keySearchByName(keyword);
        out.print(jsonArray);
    }

    public void byAuthor() throws IOException {
        out=getResponse().getWriter();
        KeySearchService keySearchService=new KeySearchService();
        JSONArray jsonArray=keySearchService.keySearchByAuthor(keyword);
        out.print(jsonArray);
    }

    public void byPublisher() throws IOException {
        out=getResponse().getWriter();
        KeySearchService keySearchService=new KeySearchService();
        JSONArray jsonArray=keySearchService.keySearchByPublisher(keyword);
        out.print(jsonArray);
    }
}
